efform_onload = function ()
{

};  
button_query_onclick = function (){
	efgrid.submitInqu( "ef_grid_result", "ZM","ZMCG50","query");
}
button_insert_onclick = function (){
	var date1=$('#inqu_status0-0-fdBeginDate').val();
	var date2=$('#inqu_status0-0-fdEndDate').val();
	if (date1 > date2){
		EFAlert("结束日期小于起始日期");
		return;
	}
//非空校验	
	var ei_info=new EiInfo();
	ei_info.setByNodeObject(document.forms[0]); 
	if(ei_info.getBlock('inqu_status0').getRows(0)[0][2]==""){
		EFAlert("起始日期不能为空");
		return;
	}
	if(ei_info.getBlock('inqu_status0').getRows(0)[0][3]==""){
		EFAlert("结束日期不能为空");
		return;
	}
//	alert(ei_info.getBlock('inqu_status0').getRows(0)[0]);return;
	if(ei_info.getBlock('inqu_status0').getRows(0)[0][4]==""){
		EFAlert("矿领导不能为空");
		return;
	}
	if(ei_info.getBlock('inqu_status0').getRows(0)[0][5]==""){
		EFAlert("调度主任不能为空");
		return;
	}
	if(ei_info.getBlock('inqu_status0').getRows(0)[0][6]==""){
		EFAlert("调度员不能为空");
		return;
	}
	
	$('#inqu_status0-0-fdMiningId').val($('#fdMiningId').val());
	var info = getDetail("ef_region_inqu1","inqu_status0");
	if (null != info) { 
		EiCommunicator.send("ZMCG50", "insert", info, ajax_callbackconfirm);
	} 
	window.location.reload(); 
}
button_update_onclick = function (){ 
	var date1=$('#inqu_status0-0-fdBeginDate').val();
	var date2=$('#inqu_status0-0-fdEndDate').val();
	if (date1 > date2){
		EFAlert("结束日期小于起始日期");
		return;
	}
	
	//非空校验	
	var ei_info=new EiInfo();
	ei_info.setByNodeObject(document.forms[0]); 
	if(ei_info.getBlock('inqu_status0').getRows(0)[0][2]==""){
		EFAlert("起始日期不能为空");
		return;
	}
	if(ei_info.getBlock('inqu_status0').getRows(0)[0][3]==""){
		EFAlert("结束日期不能为空");
		return;
	}
	
	var info = getDetail("ef_region_inqu1","inqu_status0");
	if (null != info) {
		EiCommunicator.send("ZMCG50", "update", info, ajax_callbackconfirm);
	} 
	window.location.reload(); 
}
button_delete_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return;  
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r){
			efgrid.submitForm( "ef_grid_result", "ZM","ZMCG50","delete",true);
		}
	}); 
}   
button_excute_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return;  
	EFConfirm('你确认要执行排班吗,会置换掉已排班的数据?', '确认框', function(r) {
		if(r){
			efgrid.submitForm( "ef_grid_result", "ZM","ZMCG50","excute",true);
		}
	}); 
}  
efgrid_onRowClicked = function( grid_id, row_index ){
	if(grid_id == "ef_grid_result"){ 
		var grid = efgrid.getGridObject(grid_id); 
		var selectedRow=grid.getRowData(row_index);
		for(var item in selectedRow){
			var colname=item;
			var colvalue=selectedRow[item];
			$('#ef_region_inqu1').find('#inqu_status0-0-'+colname).val(colvalue);
		} 
	}
}
var ajax_callbackconfirm = {
	onSuccess : function(eiInfo) {
		efwindow.hide(); 
		var grid = efgrid.getGridObject("ef_grid_result");
		grid.refresh(eiInfo);
	}, 
	onFail:function(eMsg)
	{
		alert("确认失败，原因："+eMsg);
	}
}
function selectMineLeader()
{ 
	var _info = new EiInfo();
	EiCommunicator.send("ZMCG50", "queryMineLeaderBlock", _info, ajax_callback1); 
};  
var ajax_callback1 = {
	onSuccess : function(eiInfo) {
		efwindow.hide(); 
		var grid = efgrid.getGridObject("ef_grid_mineleader");
		grid.refresh(eiInfo);
		EFColorbox({href:"#ef_region_mineleader",title:"选择矿领导",width:"50%", inline:true});
	},
	onFail : function(eMsg) {
	}
};
function selectDDLeader()
{ 
	var _info = new EiInfo();
	EiCommunicator.send("ZMCG50", "queryMineLeaderBlock", _info, ajax_callback2); 
};  
var ajax_callback2 = {
	onSuccess : function(eiInfo) {
		efwindow.hide(); 
		var grid = efgrid.getGridObject("ef_grid_ddleader");
		grid.refresh(eiInfo);
		EFColorbox({href:"#ef_region_ddleader",title:"选择调度主任",width:"50%", inline:true});
	},
	onFail : function(eMsg) {
	}
};
function selectDDPerson()
{ 
	var _info = new EiInfo();
	EiCommunicator.send("ZMCG50", "queryMineLeaderBlock", _info, ajax_callback3); 
};  
var ajax_callback3 = {
	onSuccess : function(eiInfo) {
		efwindow.hide(); 
		var grid = efgrid.getGridObject("ef_grid_ddperson");
		grid.refresh(eiInfo);
		EFColorbox({href:"#ef_region_ddperson",title:"选择调度员",width:"50%", inline:true});
	},
	onFail : function(eMsg) {
	}
};

button_confirm1_onclick = function ()
{   
	backSelectedPerson("ef_grid_mineleader","inqu_status0-0-fdMiningLeader");
} 
button_confirm2_onclick = function ()
{  
	backSelectedPerson("ef_grid_ddleader","inqu_status0-0-fdDdLeader");
} 
button_confirm3_onclick = function ()
{  
	backSelectedPerson("ef_grid_ddperson","inqu_status0-0-fdDdPerson"); 
} 
function backSelectedPerson(gridName,fieldId)
{
	var grid = efgrid.getGridObject(gridName); 
	var rows = grid.getCheckedRows();
	var _value=""; 
	for(var i=0;i<grid.getCheckedRows().length;i++)
	{
		_value = _value+grid.getCellValue(rows[i], 0, TYPE_DATA); 
		if(i != grid.getCheckedRows().length-1)  _value = _value +","; 
	}
	$('#'+fieldId).val(_value); 
	$("#cboxOverlay").click(); 
}